from sklearn import metrics

# https://scikit-learn.org/stable/modules/clustering.html#clustering-performance-evaluation

labels_true = [ 0,0,0,1,1,1]
labels_pred = [ 0,0,1,1,2,2]

# 即使不相同，unadjusted score可能也是1.0
print(metrics.rand_score(labels_true, labels_pred))
print(metrics.adjusted_rand_score(labels_true, labels_pred))

labels_pred = labels_true[:]
print(metrics.rand_score(labels_true, labels_pred))
print(metrics.adjusted_rand_score(labels_true, labels_pred))

# 使用NMI/AMI 指标,前者多用于论文
print(metrics.adjusted_mutual_info_score(labels_true, labels_pred),
      metrics.normalized_mutual_info_score(labels_true, labels_pred))